package com.wang.controller;

import com.wang.param.ShopQueryParam;
import com.wang.result.BaseResponse;
import com.wang.result.ResultUtils;
import com.wang.user.model.Dishes;
import com.wang.user.model.Shop;
import com.wang.user.service.DishesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/dishes")
@Api(tags = "商铺的菜品信息管理")
public class DishesController {
    @Resource
    private DishesService dishesService;

    @GetMapping("/list")
    @ApiOperation(value = "查看商铺下的所有菜品信息")
    public BaseResponse<List<Dishes>> listByShopId(ShopQueryParam queryParam) {
        return ResultUtils.success(dishesService.listByShopId(queryParam.getShopId()));
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加菜品")
    public BaseResponse<Boolean> add(@RequestBody Dishes dishes) {
        return ResultUtils.success(dishesService.add(dishes));
    }

    @PostMapping("/delete/{id}")
    @ApiOperation(value = "删除菜品")
    public BaseResponse<Boolean> add(@PathVariable Long id) {
        return ResultUtils.success(dishesService.deleteById(id));
    }
}
